/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ViewPrintPreview.java
 *
 * Created on 22.04.2010, 18:28:59
 */

package trackreggui;

import java.awt.print.Pageable;
import org.jdesktop.application.Action;
import webreg.model.swing.RegistrationPrintPreview;

/**
 *
 * @author STKNOLL
 */
public class ViewPrintPreview extends javax.swing.JDialog {

    /** Creates new form ViewPrintPreview */
    public ViewPrintPreview(java.awt.Frame parent, Pageable pageable) {
        super(parent);
        this.mPrintPreview = new RegistrationPrintPreview(pageable, 1);
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        previewToolbar = new javax.swing.JToolBar();
        previousButton = new javax.swing.JButton();
        nextButton = new javax.swing.JButton();
        pageNumberLabel = new javax.swing.JLabel();
        zoomInButton = new javax.swing.JButton();
        zoomOutButton = new javax.swing.JButton();
        closeButton = new javax.swing.JButton();
        previewScrollPane = new javax.swing.JScrollPane(this.mPrintPreview);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(trackreggui.TrackRegGuiApp.class).getContext().getResourceMap(ViewPrintPreview.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setModal(true);
        setName("Form"); // NOI18N
        getContentPane().setLayout(new java.awt.GridBagLayout());

        previewToolbar.setRollover(true);
        previewToolbar.setName("previewToolbar"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(trackreggui.TrackRegGuiApp.class).getContext().getActionMap(ViewPrintPreview.class, this);
        previousButton.setAction(actionMap.get("previousPage")); // NOI18N
        previousButton.setIcon(resourceMap.getIcon("previousButton.icon")); // NOI18N
        previousButton.setText(resourceMap.getString("previousButton.text")); // NOI18N
        previousButton.setFocusable(false);
        previousButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        previousButton.setName("previousButton"); // NOI18N
        previousButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        previewToolbar.add(previousButton);

        nextButton.setAction(actionMap.get("nextPage")); // NOI18N
        nextButton.setIcon(resourceMap.getIcon("nextButton.icon")); // NOI18N
        nextButton.setText(resourceMap.getString("nextButton.text")); // NOI18N
        nextButton.setFocusable(false);
        nextButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        nextButton.setName("nextButton"); // NOI18N
        nextButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        previewToolbar.add(nextButton);

        pageNumberLabel.setText(resourceMap.getString("pageNumberLabel.text")); // NOI18N
        pageNumberLabel.setName("pageNumberLabel"); // NOI18N
        previewToolbar.add(pageNumberLabel);

        zoomInButton.setAction(actionMap.get("zoomInPreview")); // NOI18N
        zoomInButton.setIcon(resourceMap.getIcon("zoomInButton.icon")); // NOI18N
        zoomInButton.setText(resourceMap.getString("zoomInButton.text")); // NOI18N
        zoomInButton.setFocusable(false);
        zoomInButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        zoomInButton.setName("zoomInButton"); // NOI18N
        zoomInButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        previewToolbar.add(zoomInButton);

        zoomOutButton.setAction(actionMap.get("zoomOutPreview")); // NOI18N
        zoomOutButton.setIcon(resourceMap.getIcon("zoomOutButton.icon")); // NOI18N
        zoomOutButton.setText(resourceMap.getString("zoomOutButton.text")); // NOI18N
        zoomOutButton.setFocusable(false);
        zoomOutButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        zoomOutButton.setName("zoomOutButton"); // NOI18N
        zoomOutButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        previewToolbar.add(zoomOutButton);

        closeButton.setAction(actionMap.get("closePreview")); // NOI18N
        closeButton.setText(resourceMap.getString("closeButton.text")); // NOI18N
        closeButton.setFocusable(false);
        closeButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        closeButton.setName("closeButton"); // NOI18N
        closeButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        previewToolbar.add(closeButton);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 5);
        getContentPane().add(previewToolbar, gridBagConstraints);

        previewScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        previewScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        previewScrollPane.setMinimumSize(new java.awt.Dimension(240, 400));
        previewScrollPane.setName("previewScrollPane"); // NOI18N
        previewScrollPane.setPreferredSize(new java.awt.Dimension(240, 400));
        previewScrollPane.setVerifyInputWhenFocusTarget(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        getContentPane().add(previewScrollPane, gridBagConstraints);

        pack();
    }// </editor-fold>//GEN-END:initComponents


    @Action
    public void closePreview() {
        setVisible(false);
    }

    @Action
    public void zoomInPreview() {
        mPrintPreview.changeZoom(0.1);
        mPrintPreview.repaint();
    }

    @Action
    public void zoomOutPreview() {
        mPrintPreview.changeZoom(-0.1);
        mPrintPreview.repaint();
    }

    @Action
    public void nextPage() {
        mPrintPreview.moveIndex(1);
        mPrintPreview.repaint();
    }

    @Action
    public void previousPage() {
        mPrintPreview.moveIndex(-1);
        mPrintPreview.repaint();
    }
  
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton closeButton;
    private javax.swing.JButton nextButton;
    private javax.swing.JLabel pageNumberLabel;
    private javax.swing.JScrollPane previewScrollPane;
    private javax.swing.JToolBar previewToolbar;
    private javax.swing.JButton previousButton;
    private javax.swing.JButton zoomInButton;
    private javax.swing.JButton zoomOutButton;
    // End of variables declaration//GEN-END:variables

    private RegistrationPrintPreview mPrintPreview;

}
